package com.hxd.otc.module.convenience.adapter;

import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.hxd.otc.R;
import com.hxd.otc.module.convenience.bean.ConvenienveHistoryBean;
import com.hxd.otc.utils.UIUtils;

/**
 * 包  名 :  com.hxd.otc.module.convenience.adapter
 * 类  名 :  RefuelingServiceAdapter
 * 作  者 :  zjl
 * 时  间 :  2018/12/13 11:21
 * 描  述 :  ${TODO}
 */
public class HydropwerLabelAdapter extends BaseQuickAdapter<ConvenienveHistoryBean, BaseViewHolder> {

    public HydropwerLabelAdapter() {
        super(R.layout.adapter_hydropwer_label_list, null);
    }

    @Override
    protected void convert(BaseViewHolder helper, final ConvenienveHistoryBean item) {
        helper.setText(R.id.tv_content, item.getRemark());
        if (item.flagType == 1) {
            helper.setText(R.id.tv_title, UIUtils.getContext().getString(R.string.water_fee));
            helper.setImageResource(R.id.iv_icon, R.mipmap.water_card);
        } else if (item.flagType == 2) {
            helper.setText(R.id.tv_title,  UIUtils.getContext().getString(R.string.dian_fee));
            helper.setImageResource(R.id.iv_icon, R.mipmap.lectric_card);
        }
        helper.getView(R.id.ll_delete).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (callBack != null)
                    callBack.delete(item.id);
            }
        });
        helper.getView(R.id.rl_item).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (callBack != null)
                    callBack.onClickLabel(item);
            }
        });

    }

    LabelCallBack callBack;

    public void setCallBack(LabelCallBack callBack) {
        this.callBack = callBack;
    }

    public interface LabelCallBack {

        void delete(String id);

        void onClickLabel(ConvenienveHistoryBean item);
    }
}
